<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.*,support.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	Specialization Analytics
	<p>
	<table border="1">
		<%
			Connection conn = null;
			try {
				conn = DBUtils.getConnection();
				Statement stmt = conn.createStatement();
				Statement stmt2 = conn.createStatement();
				ResultSet rset = stmt
						.executeQuery("SELECT * FROM specialization");
				// Print out the specialization and the number of applications
				while (rset.next()) {
		%>
		<tr>
			<td><%=rset.getString(1)%></td>
			<%
				ResultSet rset2 = stmt2
								.executeQuery("SELECT COUNT(*) FROM maintable where specid ='"
										+ rset.getInt(2) + "'");
						while (rset2.next()) {
			%>
			<td width="50" align="center"><a
				href="applications.jsp?action=specialization&specid=<%=rset.getInt(2)%>&specname=<%=rset.getString(1)%>"><%=rset2.getInt(1)%></a>
			</td>
			<%
				}
						rset2.close();
			%>

		</tr>

		<%
			}
				//close the result set, statement, and connection
				rset.close();
				stmt.close();
				stmt2.close();
			} catch (ServiceException e) {
				throw e;
			} catch (Exception e) {
				DBUtils.rollback(conn);
				throw new ServiceException(
						"error occur inquiring specialization");
			} finally {
				DBUtils.closeConnection(conn);
			}
		%>

	</table>

</body>
</html>